using System;

namespace AvaloniaDrawingPad.Models.Commands
{
    /// <summary>
    /// 添加图层命令
    /// </summary>
    public class AddLayerCommand : ICommand
    {
        private readonly LayerManager _layerManager;
        private readonly string _layerName;
        private Layer? _addedLayer;
        
        public string Description => "添加图层";
        
        public AddLayerCommand(LayerManager layerManager, string layerName)
        {
            _layerManager = layerManager;
            _layerName = layerName;
        }
        
        public void Execute()
        {
            // 添加图层
            _addedLayer = _layerManager.AddLayer(_layerName);
            
            // 标记项目已修改
            _layerManager.MarkAsChanged();
        }
        
        public void Undo()
        {
            if (_addedLayer != null)
            {
                // 移除图层
                _layerManager.RemoveLayer(_addedLayer);
                
                // 标记项目已修改
                _layerManager.MarkAsChanged();
            }
        }
    }
} 